package com.lancoo.ccas52.mapper;

import java.time.LocalDateTime;
import java.util.Collection;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lancoo.ccas52.entity.Student;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lancoo.ccas52.config.MybatisRedisCache;
import com.lancoo.ccas52.entity.TeachingClass;
import com.lancoo.ccas52.pojo.dto.ExcelStudent;
import com.lancoo.ccas52.pojo.vo.*;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.CacheNamespaceRef;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 学生 Mapper 接口
 * </p>
 *
 * @author quin.song
 * @since 2023-01-31
 */
@CacheNamespace(implementation = MybatisRedisCache.class, eviction = MybatisRedisCache.class)
public interface StudentMapper extends BaseMapper<Student> {

    int addBatch(@Param("studentCollection") Collection<Student> studentCollection);


    List<CollegeDto> getCollegeByTaskId(@Param("taskId") Integer taskId);

    List<GradeDto> getGrade(@Param("taskId") Integer taskId, @Param("collegeId") String collegeId, @Param("majorId") String majorId);

    List<MajorDto> getMajor(@Param("taskId") Integer taskId, @Param("collegeId") String collegeId);

    List<ClassDto> getClassDto(@Param("taskId") Integer taskId, @Param("collegeId") String collegeId, @Param("majorId") String majorId, @Param("gradeId") String gradeId);

    IPage<ClassTeachingClassDto> getClassTeachingClassDto(@Param("page") IPage page, @Param("taskId") Integer taskId, @Param("collegeId") String collegeId,
                                            @Param("keyWord") String keyWord);

    IPage<Student> getStudentByTeachingClassId(@Param("page") IPage page, @Param("teachingClassIds") List<Long> teachingClassIds);

    List<ExcelStudent> getExcelStudent(@Param("teachingClassIds") List<Long> teachingClassIds);

    /**
     * 获取学生部分信息
     * @param taskId
     * @return
     */
    Set<ExcelStudent> getStudentList(@Param("taskId") Integer taskId);

    /**
     * 获取教学计划-课程选的学生数量
     *
     * @param teachingPlanId
     * @param flag
     * @param courseId
     * @return
     */
    @Deprecated
    int getStudentCountByPlanCourse(@Param("teachingPlanId") Long teachingPlanId, @Param("flag") Integer flag, @Param("courseId") Long courseId);


    /**
     * 获取课程 获取教学班人数
     *
     * @param flag
     * @param courseId
     * @param studyNature
     * @return
     */
    int getStudentCountByCourse(@Param("flag") Integer flag, @Param("courseId") Long courseId, @Param("studyNature") Integer studyNature, @Param("teachingClassType") Integer teachingClassType);

    /**
     * 获取全部学生 条件
     *
     * @param taskId
     * @param page
     * @param collegeId
     * @param majorId
     * @param gradeId
     * @param classId
     * @param keyWord
     * @return
     */
    IPage<Student> getStudentByConditions(@Param("taskId") Integer taskId, @Param("page") IPage page, @Param("collegeId") String collegeId, @Param("majorId") String majorId,
                                          @Param("gradeId") String gradeId, @Param("classId") String classId, @Param("keyWord") String keyWord, @Param("selectionScope") Integer selectionScope);

    /**
     * 关联plan_teaching_student获取学生列表
     *
     * @param taskId
     * @param page
     * @param collegeId
     * @param majorId
     * @param gradeId
     * @param studyNature
     * @param keyWord
     * @param state
     * @return
     */
    IPage<Student> getStudentJoinLimit(@Param("taskId") Integer taskId, @Param("page") IPage page, @Param("collegeId") String collegeId, @Param("majorId") String majorId,
                                       @Param("gradeId") String gradeId, @Param("studyNature") Integer studyNature, @Param("keyWord") String keyWord, @Param("state") Integer state);

    /**
     * 获取禁选学生
     *
     * @param cssTaskId
     * @param page
     * @param collegeId
     * @param gradeId
     * @param keyWord
     * @return
     */
    IPage<StudentProhibitVo> getProhibitStudent(@Param("cssTaskId") Integer cssTaskId, @Param("page") IPage page, @Param("collegeId") String collegeId, @Param("gradeId") String gradeId, @Param("keyWord") String keyWord);


    /**
     * 获取学生选课详情
     *
     * @param taskId
     * @param page
     * @param collegeId
     * @param majorId
     * @param gradeId
     * @param classId
     * @param keyWord
     * @param teachingClassType 0无需选课 1在线选课;2:分级教学 3:预选教学班
     * @param flag              1已选   2退选   3移除 4退选+移除
     * @return
     */
    IPage<StudentCourseVo> getSelectStudent(@Param("taskId") Integer taskId, @Param("page") IPage page, @Param("collegeId") String collegeId, @Param("majorId") String majorId, @Param("gradeId") String gradeId,
                                            @Param("classId") String classId, @Param("keyWord") String keyWord, @Param("teachingClassType") Integer teachingClassType, @Param("flag") Integer flag, @Param("beginTime") LocalDateTime beginTime);

    /**
     * 根据学生id获取选课详情
     *
     * @param studentId
     * @param teachingClassType
     * @return
     */
    List<StudentCourseVo> getSelectedByStudentId(@Param("studentId") Long studentId, @Param("teachingClassType") Integer teachingClassType);

    /**
     * 获取学生选课设置信息
     *
     * @param studentId
     * @param studyNature
     * @return
     */
    Student getStudentInfoById(@Param("studentId") Long studentId, @Param("studyNature") Integer studyNature);

    /**
     * 多条件获取教学班--获取学生可选的教学班课程
     * @param page
     * @param teachingClassType
     * @param courseIds
     * @param studyNature
     * @param isExist
     * @return
     */
    @Deprecated
    IPage<TeachingClassCourseDto> getAvailableTeachingClass(@Param("page") IPage page, @Param("teachingClassType") Integer teachingClassType,
                                                            @Param("courseIds") List<Long> courseIds, @Param("studyNature") Integer studyNature, @Param("isExist") Integer isExist);


    /**
     * 获取学生可选教学班
     * @param teachingClassType
     * @param courseIds
     * @param studyNature
     * @param studentId
     * @return
     */
    List<StudentTeachingClass> getTeachingClass(@Param("teachingClassType") Integer teachingClassType,
                                                            @Param("courseIds") List<Long> courseIds, @Param("studyNature") Integer studyNature, @Param("studentId") Long studentId);

    List<StudentTeachingClass> getRetakeTeachingClass(@Param("teachingClassType") Integer teachingClassType,
                                                @Param("courseIds") List<Long> courseIds, @Param("studyNature") Integer studyNature, @Param("studentId") Long studentId);

    /**
     * 获取学生 课程教学班
     * @return
     */
    List<StudentTeachingClass> getNormalCourseTeachingClass(@Param("teachingClassIds") List<Long> teachingClassIds,@Param("teachingClassType") Integer teachingClassType);

    /**
     * 获取学生无需选课的 环节教学班
     * @return
     */
    List<StudentTeachingClass> getNormalSegmentTeachingClass(@Param("teachingClassIds") List<Long> teachingClassIds);

    /**
     * 获取行政班 教学任务设置拆班时使用
     * @param page
     * @param taskId
     * @param majorId
     * @param gradeId
     * @param keyWord
     * @param state
     * @return
     */
    IPage<ClassSubVo> getStudentClassSub(@Param("page") IPage page, @Param("taskId") Integer taskId,@Param("majorId") String majorId,
                                         @Param("gradeId") String gradeId, @Param("keyWord") String keyWord, @Param("state") Integer state);


} 
